import { IViewer, Point } from "./types";

/*
 * @Author: shijianxin
 * @Date: 2022-04-06 16:53:12
 * @Description: 小方块
 */
export class Square {
  private _point: Point = {
    x: 0,
    y: 0,
  }; // 方块坐标

  private _color: string = ""; // 方块颜色

  private _viewer?: IViewer; // 方块的显示类

  public set viewer(v) {
    this._viewer = v;
    if (v) {
      v.show();
    }
  }

  public get viewer() {
    return this._viewer;
  }

  // 获取方块坐标
  public get point() {
    return this._point;
  }

  // 设置方块坐标
  public set point(val) {
    this._point = val;
    // 完成显示
    if (this._viewer) {
      this._viewer.show();
    }
  }

  // 获取方块颜色
  public get color() {
    return this._color;
  }

  // 设置方块颜色
  public set color(val) {
    this._color = val;
  }
}
